class Localist
  module Helper
      
    def localist_menu(args={})
      @localist_menu = {:supported_locales => Localist.supported_locales,
                         :active => @localist_active_locale,
                         :symbol => Localist.symbol,
                         :template => nil}.merge(args)
      menu_template = @localist_menu.delete(:template) || 
                      File.exist?("#{RAILS_ROOT}/app/views/localist/menu.rhtml") ?
                                  "localist/menu.rhtml"   : 
                                  "/../../vendor/plugins/localist/view/menu.rhtml"
      render menu_template
    end
    
    def localist_flag_tag(locale, options={})
      country_code = Localist.country_code(locale)
      options.merge!( {:alt => country_code.upcase} )
      image_tag "localist/flags/#{country_code.downcase}.png", options
    end
        
  end # Helper

  ActionView::Base.class_eval do
    include Helper
  end
  
end 
